
from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakeEdge, BRepBuilderAPI_MakeFace
from OCC.Display.SimpleGui import init_display
from OCC.Core.GEOMAlgo import GEOMAlgo_Splitter
from OCC.Core.gp import gp_Dir, gp_Pln, gp_Pnt
from OCC.Extend.TopologyUtils import TopologyExplorer

display, start_display, add_menu, add_function_to_menu = init_display()

p0 = gp_Pnt()
vnorm = gp_Dir(1, 0, 0)
pln = gp_Pln(p0, vnorm)
face = BRepBuilderAPI_MakeFace(pln, -10, 10, -10, 10).Face()
p1 = gp_Pnt(0, 0, 15)
p2 = gp_Pnt(0, 0, -15)
edge = BRepBuilderAPI_MakeEdge(p1, p2).Edge()
# 启动分割函数
splitter = GEOMAlgo_Splitter()
# 将面作为参数，将边edge作为分割工具。
splitter.AddArgument(face)
splitter.AddTool(edge)
splitter.Perform()

#  显示分割后的面
for shape in TopologyExplorer(splitter.Shape()).faces():
    display.DisplayShape(shape,update=True)

#  显示使用的工具：边
display.DisplayShape(edge,update=True)
start_display()
